// app.js
App({
  onLaunch() {
    if(wx.getStorageSync('userInfo')){
        var loginTime = wx.getStorageSync('userInfo').loginTime

        if(this.isMoreThan28Days(loginTime)==true){
            wx.showModal({
              title: '登录已过期',
              content: '请重新登录',
              complete: (res) => {
                if (res.cancel) {
                    wx.clearStorageSync()
                    wx.reLaunch({
                      url: '/pages/mine/mine',
                    })
                }
                if (res.confirm) {
                    wx.clearStorageSync()
                    wx.reLaunch({
                      url: '/pages/mine/mine',
                    })
                }
              }
            })
        }

    }
  },
  isMoreThan28Days(dateStr) {
    const targetDate = new Date(dateStr);  // 将ISO日期字符串转换为Date对象
    const currentDate = new Date();        // 获取当前日期
  
    // 计算两个日期的差值（毫秒）
    const diff = currentDate.getTime() - targetDate.getTime();
  
    // 将差值转换为天数
    const days = diff / (1000 * 60 * 60 * 24);
  
    // 判断差值是否大于28天
    return days > 28;
  },
  globalData: {
    openid:'',
    webUrl:'',
    appTk:[],
    appEx:[],
    shenheapp:'',
    baseUrl:"http://127.0.0.1:5000",
    examCountInfo:[]
  }
})
